﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCodeProject
{
    public class Solution121
    {
        public static int MaxProfit(int[] prices)
        {
            int maxp = 0;
            int min = prices[0];
            for(int i = 0; i < prices.Length; i++)
            {
                //int ip=prices[i];
                min = min < prices[i]?min:prices[i];
                maxp = maxp < (prices[i] - min) ? (prices[i] - min) : maxp;
            }
            return maxp;
        }
    }
}
